class browser_gui :
    def __init__ ( self , mediator ) :
        self . _mediator = mediator
        self . _added_table_entry = None
        self . _application_window = None
        self . _created_button = None
        self . _created_frame = None
        self . _created_label = None
        self . _entry_text_replied = None
        self . _focus_in_event_replied = None
        self . _focus_out_event_replied = None
    def show_browser ( self ) :
        self . _create_frame ( )
    def hide_browser ( self ) :
        self . _mediator . gui_destroy_frame ( self . _frame )
    def application_window_reply ( self , window ) :
        self . _application_window = window
    def gui_create_button_reply ( self , button ) :
        self . _created_button = button
    def gui_create_frame_reply ( self , frame ) :
        self . _created_frame = frame
    def gui_create_label_reply ( self , label ) :
        self . _created_label = label
    def gui_entry_text_reply ( self , text ) :
        self . _entry_text_replied = text
    def gui_focus_in_event_reply ( self , handler ) :
        self . _focus_in_event_replied = handler
    def gui_focus_out_event_reply ( self , handler ) :
        self . _focus_out_event_replied = handler
    def add_table_entry_reply ( self , entry ) :
        self . _added_table_entry = entry
    def add_title_label_to_browser ( self , title_text ) :
        self . _label = self . _add_label ( title_text )
    def add_table_to_browser ( self ) :
        self . _mediator . create_new_table_in_frame ( self . _add_table_frame ( ) )
    def add_return_button_to_browser ( self ) :
        self . _add_button ( self . _mediator . localization_browser_return ( ) , self . _mediator . on_browser_return )
    def add_action_button_to_browser ( self , action_text ) :
        self . _add_button ( action_text , self . _mediator . on_browser_action_gui_button )
    def add_title_row_to_browser ( self , number , name , creation_time , modification_time , size ) :
        self . _mediator . add_table_label ( number )
        self . _mediator . add_table_label ( name )
        self . _mediator . add_table_label ( creation_time )
        self . _mediator . add_table_label ( modification_time )
        self . _mediator . add_table_label ( size )
        self . _mediator . finish_table_row ( )
    def add_existing_row_to_browser ( self , number , name , creation_time , modification_time , size ) :
        self . _mediator . add_table_label ( number )
        self . _mediator . add_table_label ( name , anchor = self . _mediator . gui_anchor_w ( ) )
        self . _mediator . add_table_label ( creation_time )
        self . _mediator . add_table_label ( modification_time )
        self . _mediator . add_table_label ( size , anchor = self . _mediator . gui_anchor_e ( ) )
        self . _mediator . finish_table_row ( )
    def add_empty_row_to_browser ( self ) :
        for col in xrange ( 5 ) :
            self . _mediator . add_table_label ( borderwidth = 0 )
        self . _mediator . finish_table_row ( )
    def add_action_row_to_browser ( self ) :
        self . _mediator . add_table_label ( )
        self . _mediator . add_table_entry_request ( )
        self . _entry = self . _added_table_entry
        self . _mediator . gui_focus_in_event_request ( self . _entry , self . _mediator . on_browser_entry_focus )
        self . _entry_focus_event = self . _focus_in_event_replied
        self . _mediator . gui_focus_out_event_request ( self . _entry , self . _mediator . on_browser_entry_unfocus )
        self . _entry_unfocus_event = self . _focus_out_event_replied
        self . _mediator . add_table_label ( )
        self . _mediator . add_table_label ( )
        self . _mediator . add_table_label ( )
        self . _mediator . finish_table_row ( )
    def focus_entry_in_browser ( self ) :
        self . _mediator . gui_move_focus_to ( self . _entry )
    def unfocus_entry_in_browser ( self ) :
        self . _mediator . gui_move_focus_to ( self . _frame )
    def entry_text_in_browser_request ( self ) :
        self . _mediator . gui_entry_text_request ( self . _entry )
        self . _mediator . entry_text_in_browser_reply ( self . _entry_text_replied )
    def set_entry_text_in_browser ( self , text ) :
        self . _mediator . gui_set_entry_text ( self . _entry , text )
    def set_title_text_in_browser ( self , text ) :
        self . _mediator . gui_set_label_text ( self . _label , text )
    def _create_frame ( self ) :
        self . _mediator . application_window_request ( )
        self . _mediator . gui_create_frame_request ( self . _application_window )
        self . _frame = self . _created_frame
        self . _mediator . gui_pack ( widget = self . _frame , padx = 10 , pady = 10 )
    def _add_label ( self , text ) :
        self . _mediator . gui_create_label_request ( master = self . _frame , text = text )
        label = self . _created_label
        self . _mediator . gui_pack \
            ( widget = label
            , side = self . _mediator . gui_side_top ( )
            , fill = self . _mediator . gui_fill_x ( )
            )
        return label
    def _add_table_frame ( self ) :
        self . _mediator . gui_create_frame_request ( self . _frame )
        frame = self . _created_frame
        self . _mediator . gui_pack \
            ( widget = frame
            , side = self . _mediator . gui_side_top ( )
            , fill = self . _mediator . gui_fill_x ( )
            )
        return frame
    def _add_button ( self , text , command ) :
        self . _mediator . gui_create_button_request \
            ( master = self . _frame 
            , text = text
            , command = command
            )
        self . _mediator . gui_pack ( widget = self . _created_button , side = self . _mediator . gui_side_top ( ) )
